/*
 * FileName: CBall.cs
 * Module: Core
 * Author: Gourav Das
 * Created: 04/2011
 * Modifications:
 * Copyright: Gourav Das, 2011
 */

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace _22yards.Core
{
    /// <summary>
    /// A very important class which holds all important information about 1 ball bowled.
    /// </summary>
    public class CBall
    {

        /// <summary>
        /// Gets or sets the over number.
        /// </summary>
        /// <value>
        /// The over number this ball is part of
        /// </value>
        public int OverNumber { get; set; }

        /// <summary>
        /// Gets or sets the bowler ID.
        /// </summary>
        /// <value>
        /// The bowler ID from cPlayer Class
        /// </value>
        public int BowlerID { get; set; }

        /// <summary>
        /// Gets or sets the speed in KM.
        /// </summary>
        /// <value>
        /// The speed in KM.
        /// </value>
        public float SpeedInKM { get; set; }

        /// <summary>
        /// Gets or sets the runs scored of bat.
        /// </summary>
        /// <value>
        /// The runs scored of bat.
        /// </value>
        public short RunsScoredOfBat { get; set; }

        /// <summary>
        /// Gets or sets the runs scored because extra.
        /// </summary>
        /// <value>
        /// The runs scored because of extra.
        /// </value>
        public short RunsScoredBecauseExtra { get; set; }

        /// <summary>
        /// Gets or sets the batsman ID.
        /// </summary>
        /// <value>
        /// The batsman ID who will face the ball
        /// </value>
        public int BatsmanID { get; set; }

        /// <summary>
        /// Gets or sets the batsman shot direction.
        /// </summary>
        /// <value>
        /// The batsman shot direction.
        /// </value>
        public short BatsmanShotDirection { get; set; }
        /// <summary>
        /// Gets or sets the out batsman ID.
        /// </summary>
        /// <value>
        /// The batsman ID. This can be different than batsman who faced ball. Ex - runout.
        /// </value>
        public int OutBatsmanID { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether [got wicket].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [got wicket]; otherwise, <c>false</c>.
        /// </value>
        public bool GotWicket { get; set; }

        /// <summary>
        /// Gets or sets the bowling area.
        /// </summary>
        /// <value>
        /// The bowling area.
        /// </value>
        public short BowlingArea { get; set; }


        /// <summary>
        /// Gets or sets the out style.
        /// </summary>
        /// <value>
        /// 1 - bowled, 2 - Caught Behind, 3 - CaughtOtherPlayer, 6 - Run Out, 4 - Hit Wicket, 5 - Stumped 7 - Timed out, 8 - Obstructing field, 9 - Handling ball
        /// </value>
        public short OutStyle { get; set; }

        /// <summary>
        /// Gets or sets the player's ID responsible for the dismissal
        /// </summary>
        /// <value>
        /// The player's ID who was responsible for the out
        /// </value>
        public int Responsible4OutPlayerID { get; set; }

        /// <summary>
        /// Gets or sets the type of extra.
        /// </summary>
        /// <value>
        /// 0 - Normal, 1 - wide, 2- OverStep, 3 - AboveWaist, 4 - LegBye, 5-Bye, 6 - HitHelmet, 7 - Deadball
        /// </value>
        public short TypeOfExtra { get; set; }

        /// <summary>
        /// Gets the speed in Miles.
        /// </summary>
        public float SpeedInMiles
        {
            get
            {
                return SpeedInKM * 0.62f;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [hit four].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [hit four]; otherwise, <c>false</c>.
        /// </value>
        public bool HitFour { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether [hit six].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [hit six]; otherwise, <c>false</c>.
        /// </value>
        public bool HitSix { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="CBall"/> class.
        /// </summary>
        /// <param name="_bowlerID">The Bowler ID.</param>
        /// <param name="_speedinkm">The SpeedInKM.</param>
        /// <param name="_runsofbat">The Runs scored of bat.</param>
        /// <param name="_runsofextra">The Runs scored of extra.</param>
        /// <param name="_batsmanid">The Batsman ID.</param>
        /// <param name="_outbastmanid">The Bastman's ID who got out.</param>
        /// <param name="_typeofextra">The Type of extra.</param>
        /// <param name="_isOut">If this ball got a wicket</param>
        public CBall(int _bowlerID, float _speedinkm, short _runsofbat,short _runsofextra, int _batsmanid,short _shotdir
            , int _outbastmanid, short _typeofextra, bool _isOut, short _bowlingarea
            , bool _hitfour, bool _hitsix
            , short _outstyle, int _responsibleForOutID, int _overnumber )
        {
            BowlerID = _bowlerID ;
            SpeedInKM = _speedinkm;
            RunsScoredOfBat = _runsofbat;
            RunsScoredBecauseExtra = _runsofextra;
            BatsmanID = _batsmanid;
            OutBatsmanID = _outbastmanid;
            BatsmanShotDirection = _shotdir;
            TypeOfExtra = _typeofextra;
            GotWicket = _isOut;
            BowlingArea = _bowlingarea;
            HitFour = _hitfour;
            HitSix = _hitsix;
            OutStyle = _outstyle;
            Responsible4OutPlayerID = _responsibleForOutID;
            OverNumber = _overnumber;
        }

    }
}
